package com.lsq.wuyuge.dto;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 分页结果数据传输对象
 */
@Data
public class PageResultDTO<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 总记录数
     */
    private long total;

    /**
     * 当前页码
     */
    private int pageNum;

    /**
     * 每页记录数
     */
    private int pageSize;

    /**
     * 总页数
     */
    private int pages;

    /**
     * 分页数据
     */
    private List<T> list;

    /**
     * 是否有上一页
     */
    private boolean hasPrevious;

    /**
     * 是否有下一页
     */
    private boolean hasNext;

    public PageResultDTO() {
    }

    public PageResultDTO(long total, int pageNum, int pageSize, List<T> list) {
        this.total = total;
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.list = list;
        this.pages = (int) (total % pageSize == 0 ? total / pageSize : total / pageSize + 1);
        this.hasPrevious = pageNum > 1;
        this.hasNext = pageNum < pages;
    }
} 